<!doctype html>



  


<html class="theme-next mist use-motion" lang="zh-Hans">
<head>
  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>



<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />









  <meta name="baidu-site-verification" content="Q7ugSRSO7V" />







  
  
  <link href="/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />




  
  
  
  

  
    
    
  

  

  

  

  

  
    
    
    <link href="//fonts.googleapis.com/css?family=Lato:300,300italic,400,400italic,700,700italic&subset=latin,latin-ext" rel="stylesheet" type="text/css">
  






<link href="/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css" />

<link href="/css/main.css?v=5.1.0" rel="stylesheet" type="text/css" />


  <meta name="keywords" content="Hexo, NexT" />








  <link rel="shortcut icon" type="image/x-icon" href="/favicon.ico?v=5.1.0" />






<meta name="description" content="使用openssh生成公钥与私钥openssl genrsa -out rsa_private_key.pem 1024openssl pkcs8 -topk8 -inform PEM -in rsa_private_key.pem -outform PEM -nocrypt -out private_key.pemopenssl rsa -in rsa_private_key.pem -pubo">
<meta property="og:type" content="article">
<meta property="og:title" content="公钥与私钥">
<meta property="og:url" content="http://yoursite.com/security/公钥与私钥/index.html">
<meta property="og:site_name" content="chimps">
<meta property="og:description" content="使用openssh生成公钥与私钥openssl genrsa -out rsa_private_key.pem 1024openssl pkcs8 -topk8 -inform PEM -in rsa_private_key.pem -outform PEM -nocrypt -out private_key.pemopenssl rsa -in rsa_private_key.pem -pubo">
<meta property="og:updated_time" content="2017-04-23T14:48:26.000Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="公钥与私钥">
<meta name="twitter:description" content="使用openssh生成公钥与私钥openssl genrsa -out rsa_private_key.pem 1024openssl pkcs8 -topk8 -inform PEM -in rsa_private_key.pem -outform PEM -nocrypt -out private_key.pemopenssl rsa -in rsa_private_key.pem -pubo">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Mist',
    sidebar: {"position":"left","display":"hide","offset":12,"offset_float":0,"b2t":false,"scrollpercent":false},
    fancybox: true,
    motion: true,
    duoshuo: {
      userId: '0',
      author: '博主'
    },
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":30},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>



  <link rel="canonical" href="http://yoursite.com/security/公钥与私钥/"/>





  <title> 公钥与私钥 | chimps </title>
</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">

  





  <script type="text/javascript">
    var _hmt = _hmt || [];
    (function() {
      var hm = document.createElement("script");
      hm.src = "https://hm.baidu.com/hm.js?dcb994042608bdb310eff950ba755ff1";
      var s = document.getElementsByTagName("script")[0];
      s.parentNode.insertBefore(hm, s);
    })();
  </script>










  
  
    
  

  <div class="container sidebar-position-left page-post-detail ">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/"  class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">chimps</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
      
        <p class="site-subtitle"></p>
      
  </div>

  <div class="site-nav-toggle">
    <button>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br />
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-categories">
          <a href="/categories" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-th"></i> <br />
            
            分类
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/archives" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-archive"></i> <br />
            
            归档
          </a>
        </li>
      
        
        <li class="menu-item menu-item-tags">
          <a href="/tags" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-tags"></i> <br />
            
            标签
          </a>
        </li>
      

      
    </ul>
  

  
</nav>



 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  <article class="post post-type-normal " itemscope itemtype="http://schema.org/Article">
    <link itemprop="mainEntityOfPage" href="http://yoursite.com/security/公钥与私钥/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="chimps">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="https://sfault-avatar.b0.upaiyun.com/416/326/4163260007-58a1621e63a68_huge256">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="chimps">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
            
            
              
                公钥与私钥
              
            
          </h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2017-04-23T22:46:32+08:00">
                2017-04-23
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/security/" itemprop="url" rel="index">
                    <span itemprop="name">security</span>
                  </a>
                </span>

                
                
              
            </span>
          

          
            
              <span class="post-comments-count">
                <span class="post-meta-divider">|</span>
                <span class="post-meta-item-icon">
                  <i class="fa fa-comment-o"></i>
                </span>
                <a class="cloud-tie-join-count" href="/security/公钥与私钥/#comments" itemprop="discussionUrl">
                  <span class="post-comments-count join-count" itemprop="commentCount"></span>
                </a>
              </span>
            
          

          
          

          

          

          

        </div>
      </header>
    


    <div class="post-body" itemprop="articleBody">

      
      

      
        <h1 id="使用openssh生成公钥与私钥"><a href="#使用openssh生成公钥与私钥" class="headerlink" title="使用openssh生成公钥与私钥"></a>使用openssh生成公钥与私钥</h1><figure class="highlight plain"><table><tr><td class="code"><pre><div class="line">openssl genrsa -out rsa_private_key.pem 1024</div><div class="line">openssl pkcs8 -topk8 -inform PEM -in rsa_private_key.pem -outform PEM -nocrypt -out private_key.pem</div><div class="line">openssl rsa -in rsa_private_key.pem -pubout -out rsa_public_key.pem</div></pre></td></tr></table></figure>
<h1 id="RSA私钥"><a href="#RSA私钥" class="headerlink" title="RSA私钥"></a>RSA私钥</h1><figure class="highlight sh"><table><tr><td class="code"><pre><div class="line"><span class="variable">$private_key</span> = <span class="string">'-----BEGIN RSA PRIVATE KEY-----</span></div><div class="line">MIICXQIBAAKBgQC3//sR2tXw0wrC2DySx8vNGlqt3Y7ldU9+LBLI6e1KS5lfc5jl</div><div class="line">TGF7KBTSkCHBM3ouEHWqp1ZJ85iJe59aF5gIB2klBd6h4wrbbHA2XE1sq21ykja/</div><div class="line">Gqx7/IRia3zQfxGv/qEkyGOx+XALVoOlZqDwh76o2n1vP1D+tD3amHsK7QIDAQAB</div><div class="line">AoGBAKH14bMitESqD4PYwODWmy7rrrvyFPEnJJTECLjvKB7IkrVxVDkp1XiJnGKH</div><div class="line">2h5syHQ5qslPSGYJ1M/XkDnGINwaLVHVD3BoKKgKg1bZn7ao5pXT+herqxaVwWs6</div><div class="line">ga63yVSIC8jcODxiuvxJnUMQRLaqoF6aUb/2VWc2T5MDmxLhAkEA3pwGpvXgLiWL</div><div class="line">3h7QLYZLrLrbFRuRN4CYl4UYaAKokkAvZly04Glle8ycgOc2DzL4eiL4l/+x/gaq</div><div class="line">deJU/cHLRQJBANOZY0mEoVkwhU4bScSdnfM6usQowYBEwHYYh/OTv1a3SqcCE1f+</div><div class="line">qbAclCqeNiHajCcDmgYJ53LfIgyv0wCS54kCQAXaPkaHclRkQlAdqUV5IWYyJ25f</div><div class="line">oiq+Y8SgCCs73qixrU1YpJy9yKA/meG9smsl4Oh9IOIGI+zUygh9YdSmEq0CQQC2</div><div class="line">4G3IP2G3lNDRdZIm5NZ7PfnmyRabxk/UgVUWdk47IwTZHFkdhxKfC8QepUhBsAHL</div><div class="line">QjifGXY4eJKUBm3FpDGJAkAFwUxYssiJjvrHwnHFbg0rFkvvY63OSmnRxiL4X6EY</div><div class="line">yI9lblCsyfpl25l7l5zmJrAHn45zAiOoBrWqpM5edu7c</div><div class="line">-----END RSA PRIVATE KEY-----';</div></pre></td></tr></table></figure>
<h1 id="RSA公钥"><a href="#RSA公钥" class="headerlink" title="RSA公钥"></a>RSA公钥</h1><figure class="highlight"><table><tr><td class="code"><pre><div class="line">$public_key = '-----BEGIN PUBLIC KEY-----</div><div class="line">MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC3//sR2tXw0wrC2DySx8vNGlqt</div><div class="line">3Y7ldU9+LBLI6e1KS5lfc5jlTGF7KBTSkCHBM3ouEHWqp1ZJ85iJe59aF5gIB2kl</div><div class="line">Bd6h4wrbbHA2XE1sq21ykja/Gqx7/IRia3zQfxGv/qEkyGOx+XALVoOlZqDwh76o</div><div class="line">2n1vP1D+tD3amHsK7QIDAQAB</div><div class="line">-----END PUBLIC KEY-----';</div><div class="line"></div><div class="line">$pi_key =  openssl_pkey_get_private($private_key);//这个函数可用来判断私钥是否是可用的，可用返回资源id </div><div class="line">$pu_key = openssl_pkey_get_public($public_key);//这个函数可用来判断公钥是否是可用的</div><div class="line">print_r($pi_key);echo "\n";</div><div class="line">print_r($pu_key);echo "\n";</div></pre></td></tr></table></figure>
<h1 id="私钥加密公钥解密"><a href="#私钥加密公钥解密" class="headerlink" title="私钥加密公钥解密"></a>私钥加密公钥解密</h1><figure class="highlight php"><table><tr><td class="code"><pre><div class="line">$data = “aassssasssddd”;<span class="comment">//原始数据</span></div><div class="line">$encrypted = <span class="string">""</span>; </div><div class="line">$decrypted = <span class="string">""</span>; </div><div class="line"></div><div class="line"><span class="keyword">echo</span> <span class="string">"source data:"</span>,$data,<span class="string">"\n"</span>;</div><div class="line"></div><div class="line"><span class="keyword">echo</span> <span class="string">"private key encrypt:\n"</span>;</div><div class="line"></div><div class="line">openssl_private_encrypt($data,$encrypted,$pi_key);<span class="comment">//私钥加密</span></div><div class="line">$encrypted = base64_encode($encrypted);<span class="comment">//加密后的内容通常含有特殊字符，需要编码转换下，在网络间通过url传输时要注意base64编码是否是url安全的</span></div><div class="line"><span class="keyword">echo</span> $encrypted,<span class="string">"\n"</span>;</div><div class="line"></div><div class="line"><span class="keyword">echo</span> <span class="string">"public key decrypt:\n"</span>;</div><div class="line"></div><div class="line">openssl_public_decrypt(base64_decode($encrypted),$decrypted,$pu_key);<span class="comment">//私钥加密的内容通过公钥可用解密出来</span></div><div class="line"><span class="keyword">echo</span> $decrypted,<span class="string">"\n"</span>;</div><div class="line"></div><div class="line"><span class="keyword">echo</span> <span class="string">"---------------------------------------\n"</span>;</div><div class="line"><span class="keyword">echo</span> <span class="string">"public key encrypt:\n"</span>;</div></pre></td></tr></table></figure>
<h1 id="公钥加密私钥解密"><a href="#公钥加密私钥解密" class="headerlink" title="公钥加密私钥解密"></a>公钥加密私钥解密</h1><figure class="highlight php"><table><tr><td class="code"><pre><div class="line">openssl_public_encrypt($data,$encrypted,$pu_key);<span class="comment">//公钥加密</span></div><div class="line">$encrypted = base64_encode($encrypted);</div><div class="line"><span class="keyword">echo</span> $encrypted,<span class="string">"\n"</span>;</div><div class="line"></div><div class="line"><span class="keyword">echo</span> <span class="string">"private key decrypt:\n"</span>;</div><div class="line">openssl_private_decrypt(base64_decode($encrypted),$decrypted,$pi_key);<span class="comment">//私钥解密</span></div><div class="line"><span class="keyword">echo</span> $decrypted,<span class="string">"\n"</span>;</div></pre></td></tr></table></figure>
<h1 id="RSA签名"><a href="#RSA签名" class="headerlink" title="RSA签名"></a>RSA签名</h1><figure class="highlight php"><table><tr><td class="code"><pre><div class="line"><span class="comment">/**</span></div><div class="line"> * $data待签名数据</div><div class="line"> * 签名用商户私钥，必须是没有经过pkcs8转换的私钥</div><div class="line"> * 最后的签名，需要用base64编码</div><div class="line"> * return Sign签名</div><div class="line"> */</div><div class="line"><span class="function"><span class="keyword">function</span> <span class="title">sign</span><span class="params">($data)</span> </span>&#123;</div><div class="line">    <span class="comment">//读取私钥文件</span></div><div class="line">    $priKey = file_get_contents(<span class="string">'key/rsa_private_key.pem'</span>);</div><div class="line">    <span class="comment">//转换为openssl密钥，必须是没有经过pkcs8转换的私钥</span></div><div class="line">    $res = openssl_get_privatekey($priKey);</div><div class="line">    <span class="comment">//调用openssl内置签名方法，生成签名$sign</span></div><div class="line">    openssl_sign($data, $sign, $res);</div><div class="line">    <span class="comment">//释放资源</span></div><div class="line">    openssl_free_key($res);</div><div class="line">    <span class="comment">//base64编码</span></div><div class="line">    $sign = base64_encode($sign);</div><div class="line">    <span class="keyword">return</span> $sign;</div><div class="line">&#125;</div></pre></td></tr></table></figure>
<h1 id="RSA验签"><a href="#RSA验签" class="headerlink" title="RSA验签"></a>RSA验签</h1><figure class="highlight php"><table><tr><td class="code"><pre><div class="line"><span class="comment">/**</span></div><div class="line"> * $data待签名数据</div><div class="line"> * $sign需要验签的签名</div><div class="line"> * 验签用支付宝公钥</div><div class="line"> * return 验签是否通过 bool值</div><div class="line"> */</div><div class="line"><span class="function"><span class="keyword">function</span> <span class="title">verify</span><span class="params">($data, $sign)</span>  </span>&#123; </div><div class="line">    <span class="comment">//读取支付宝公钥文件</span></div><div class="line">    $pubKey = file_get_contents(<span class="string">'key/alipay_public_key.pem'</span>);</div><div class="line">    <span class="comment">//转换为openssl格式密钥</span></div><div class="line">    $res = openssl_get_publickey($pubKey);</div><div class="line">    <span class="comment">//调用openssl内置方法验签，返回bool值</span></div><div class="line">    $result = (bool)openssl_verify($data, base64_decode($sign), $res);</div><div class="line">    <span class="comment">//释放资源</span></div><div class="line">    openssl_free_key($res);</div><div class="line">    <span class="comment">//返回资源是否成功</span></div><div class="line">    <span class="keyword">return</span> $result;</div><div class="line">&#125;</div></pre></td></tr></table></figure>
<h1 id="demo"><a href="#demo" class="headerlink" title="demo"></a>demo</h1><figure class="highlight"><table><tr><td class="code"><pre><div class="line">&lt;?php</div><div class="line"></div><div class="line">function sign($data) &#123;</div><div class="line">    $private_key = "-----BEGIN PRIVATE KEY-----</div><div class="line">MIICeQIBADANBgkqhkiG9w0BAQEFAASCAmMwggJfAgEAAoGBAK0tP+ugR/9y4PUj</div><div class="line">5vCpJhxZ24MIafotWXZ4ccw8Vusa7904bp7J84wJK9z3siiKzyRjjMw+ghDAuNyG</div><div class="line">Ruv27hw8FgLK6FB5uZ8TQraA49ml6pJdB2f0t727S56et30ZBYIEp6SJXH/rlf6m</div><div class="line">Q0TuR+M+ls/6CrWgXHKMKTXuqcsDAgMBAAECgYEAjP3zNbZYB90S0+K4CiXc1mY+</div><div class="line">Nq9qAPpdBPxIwhw6M83JjhV80qDfPZrV8GBl12Y0AY9fOYaGxHbzyu8z3Lc84b8U</div><div class="line">zFK0MeHrbbeE9FTiqCrkZEZnydMtaluUAY+fn8BIC6GnKl66x58vUUnJsz9CvolA</div><div class="line">/uFNR94A06k2yLcwtVkCQQDVNg6amLLZ3jXlfW+XtPdP+m62Gne+soXiIbcx3xz/</div><div class="line">D2al/0PWMkImssq7v2Qfpvz1quGxTPmBpEodDrSLb5F3AkEAz+5iSHYD21+IFQZX</div><div class="line">daGbEziRLwHbHqdSPc1VTZEnbLOdF1uHtjwj9OtWdJfXiHWuaeUS8XjOzTIGhb9S</div><div class="line">fREV1QJBAJrJBc0iMiWM9p/Gcq82R50eeCVoDaq5vAyw4WgpS8m3ipPUP5FPJ0sk</div><div class="line">3Z1zkuKPvnEzP2oSMcj2Vn/F3zijJH0CQQDMX+L6lgT0etGm2LTeShnCqrcJHSni</div><div class="line">11Neq5RMyX+WuHSPoMejtzkgYrB3qUeQORtVunMEJVofFiyTCZpqk4CBAkEAkgPh</div><div class="line">trrYsoCm0xziyfv8zX+8p2LqvbvvY7cH5voFXc5aHrMOkyJyxhUr/KD/WayRwWMi</div><div class="line">M8NRqHC2ko8WjlYUxw==</div><div class="line">-----END PRIVATE KEY-----";</div><div class="line">    $res = openssl_get_privatekey($private_key);</div><div class="line">    //调用openssl内置签名方法，生成签名$sign</div><div class="line">    openssl_sign($data, $sign, $res);</div><div class="line">    //释放资源</div><div class="line">    openssl_free_key($res);</div><div class="line">    //base64编码</div><div class="line">    $sign = base64_encode($sign);</div><div class="line">    return $sign;</div><div class="line">&#125;</div><div class="line"></div><div class="line">function verify($data, $encrypted)&#123;</div><div class="line">    $public_key = "-----BEGIN PUBLIC KEY-----</div><div class="line">MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCtLT/roEf/cuD1I+bwqSYcWduD</div><div class="line">CGn6LVl2eHHMPFbrGu/dOG6eyfOMCSvc97Iois8kY4zMPoIQwLjchkbr9u4cPBYC</div><div class="line">yuhQebmfE0K2gOPZpeqSXQdn9Le9u0uenrd9GQWCBKekiVx/65X+pkNE7kfjPpbP</div><div class="line">+gq1oFxyjCk17qnLAwIDAQAB</div><div class="line">-----END PUBLIC KEY-----";</div><div class="line">    $res = openssl_get_publickey($public_key);</div><div class="line">    $result = (bool)openssl_verify($data, base64_decode($encrypted), $res);</div><div class="line">    openssl_free_key($res);</div><div class="line">    return $result;</div><div class="line">&#125;</div><div class="line"></div><div class="line">$data = "hello sign";</div><div class="line"></div><div class="line">$encrypted = sign($data);</div><div class="line">echo "encrypted: \n";</div><div class="line">echo $encrypted . "\n";</div><div class="line"></div><div class="line">$res = verify($data, $encrypted);</div><div class="line"></div><div class="line">echo "decrypted: \n";</div><div class="line">var_dump($res);</div></pre></td></tr></table></figure>
      
    </div>

    <div>
      
        

      
    </div>

    <div>
      
        

      
    </div>

    <div>
      
        

      
    </div>

    <footer class="post-footer">
      

      
        
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/php/设计模式/" rel="next" title="">
                <i class="fa fa-chevron-left"></i> 
              </a>
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/http/header/" rel="prev" title="header">
                header <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </article>



    <div class="post-spread">
      
    </div>
  </div>


          </div>
          


          
  <div class="comments" id="comments">
    
      <div id="cloud-tie-wrapper" class="cloud-tie-wrapper"></div>
    
  </div>


        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap" >
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview">
            站点概览
          </li>
        </ul>
      

      <section class="site-overview sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
          <img class="site-author-image" itemprop="image"
               src="https://sfault-avatar.b0.upaiyun.com/416/326/4163260007-58a1621e63a68_huge256"
               alt="chimps" />
          <p class="site-author-name" itemprop="name">chimps</p>
           
              <p class="site-description motion-element" itemprop="description"></p>
          
        </div>
        <nav class="site-state motion-element">

          
            <div class="site-state-item site-state-posts">
              <a href="/archives">
                <span class="site-state-item-count">59</span>
                <span class="site-state-item-name">日志</span>
              </a>
            </div>
          

          
            
            
            <div class="site-state-item site-state-categories">
              <a href="/categories/index.html">
                <span class="site-state-item-count">12</span>
                <span class="site-state-item-name">分类</span>
              </a>
            </div>
          

          
            
            
            <div class="site-state-item site-state-tags">
              <a href="/tags/index.html">
                <span class="site-state-item-count">19</span>
                <span class="site-state-item-name">标签</span>
              </a>
            </div>
          

        </nav>

        

        <div class="links-of-author motion-element">
          
        </div>

        
        

        
        

        


      </section>

      
      <!--noindex-->
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">

            
              
            

            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-1"><a class="nav-link" href="#使用openssh生成公钥与私钥"><span class="nav-number">1.</span> <span class="nav-text">使用openssh生成公钥与私钥</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#RSA私钥"><span class="nav-number">2.</span> <span class="nav-text">RSA私钥</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#RSA公钥"><span class="nav-number">3.</span> <span class="nav-text">RSA公钥</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#私钥加密公钥解密"><span class="nav-number">4.</span> <span class="nav-text">私钥加密公钥解密</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#公钥加密私钥解密"><span class="nav-number">5.</span> <span class="nav-text">公钥加密私钥解密</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#RSA签名"><span class="nav-number">6.</span> <span class="nav-text">RSA签名</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#RSA验签"><span class="nav-number">7.</span> <span class="nav-text">RSA验签</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#demo"><span class="nav-number">8.</span> <span class="nav-text">demo</span></a></li></ol></div>
            

          </div>
        </section>
      <!--/noindex-->
      

      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright" >
  
  &copy; 
  <span itemprop="copyrightYear">2017</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">chimps</span>
</div>


<div class="powered-by">
  由 <a class="theme-link" href="https://hexo.io">Hexo</a> 强力驱动
</div>

<div class="theme-info">
  主题 -
  <a class="theme-link" href="https://github.com/iissnan/hexo-theme-next">
    NexT.Mist
  </a>
</div>


        

        
      </div>
    </footer>

    
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
        
      </div>
    

  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  








  
  <script type="text/javascript" src="/lib/jquery/index.js?v=2.1.3"></script>

  
  <script type="text/javascript" src="/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>

  
  <script type="text/javascript" src="/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>

  
  <script type="text/javascript" src="/lib/velocity/velocity.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>


  


  <script type="text/javascript" src="/js/src/utils.js?v=5.1.0"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=5.1.0"></script>



  
  

  
  <script type="text/javascript" src="/js/src/scrollspy.js?v=5.1.0"></script>
<script type="text/javascript" src="/js/src/post-details.js?v=5.1.0"></script>



  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=5.1.0"></script>



  


  




	





  
    
    <script>
      var cloudTieConfig = {
        url: document.location.href, 
        sourceId: "",
        productKey: "48bb30d8783d4b38ba0c95e0283238ca",
        target: "cloud-tie-wrapper"
      };
    </script>
    <script src="https://img1.ws.126.net/f2e/tie/yun/sdk/loader.js"></script>
  










  





  

  
<script>
(function(){
    var bp = document.createElement('script');
    var curProtocol = window.location.protocol.split(':')[0];
    if (curProtocol === 'https') {
        bp.src = 'https://zz.bdstatic.com/linksubmit/push.js';        
    }
    else {
        bp.src = 'http://push.zhanzhang.baidu.com/push.js';
    }
    var s = document.getElementsByTagName("script")[0];
    s.parentNode.insertBefore(bp, s);
})();
</script>


  

  

  

</body>
</html>
